{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Setup Box Client\n",
    "from box_sdk_gen import DeveloperTokenConfig, BoxDeveloperTokenAuth, BoxClient\n",
    "\n",
    "BOX_DEV_TOKEN = \"your_box_dev_token\"\n",
    "\n",
    "config = DeveloperTokenConfig(BOX_DEV_TOKEN)\n",
    "auth = BoxDeveloperTokenAuth(config)\n",
    "box_client = BoxClient(auth)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "os.environ[\"OPENAI_API_KEY\"] = \"your-key\"\n",
    "\n",
    "from llama_index.core.agent.workflow import FunctionAgent\n",
    "from llama_index.llms.openai import OpenAI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Import and initialize Box tool spec\n",
    "\n",
    "from llama_index.tools.box import BoxSearchToolSpec\n",
    "\n",
    "box_tool_spec = BoxSearchToolSpec(box_client)\n",
    "\n",
    "# Create an agent with the Box tool spec\n",
    "agent = FunctionAgent(\n",
    "    tools=box_tool_spec.to_tool_list(),\n",
    "    llm=OpenAI(model=\"gpt-4.1\"),\n",
    ")\n",
    "\n",
    "answer = await agent.run(\"search all invoices\")\n",
    "print(answer)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```\n",
    "I found the following invoices:\n",
    "\n",
    "1. **Invoice-A5555.txt**\n",
    "   - Size: 150 bytes\n",
    "   - Created By: RB Admin\n",
    "   - Created At: 2024-04-30 06:22:18\n",
    "\n",
    "2. **Invoice-Q2468.txt**\n",
    "   - Size: 176 bytes\n",
    "   - Created By: RB Admin\n",
    "   - Created At: 2024-04-30 06:22:19\n",
    "\n",
    "3. **Invoice-B1234.txt**\n",
    "   - Size: 168 bytes\n",
    "   - Created By: RB Admin\n",
    "   - Created At: 2024-04-30 06:22:15\n",
    "\n",
    "4. **Invoice-Q8888.txt**\n",
    "   - Size: 164 bytes\n",
    "   - Created By: RB Admin\n",
    "   - Created At: 2024-04-30 06:22:14\n",
    "\n",
    "5. **Invoice-C9876.txt**\n",
    "   - Size: 189 bytes\n",
    "   - Created By: RB Admin\n",
    "   - Created At: 2024-04-30 06:22:17\n",
    "\n",
    "These are the invoices found in the search. Let me know if you need more information or assistance with these invoices.\n",
    "```"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "llama-index-readers-box-9HYYEbiN-py3.12",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
